clear all

*********Set working directory and load data
local user: env USERNAME
if "`user'" == "ENTERYOURNAME"  cd "SETYOURDIRECTORY"
else if "`user'" == "sagomm"  cd "C:\Users\sagomm\Dropbox\SEP-Trust\Analysis\" 

use "Data\w9_conjoint.dta"

******Install necesarry user-written commands
do "Scripts\functions\function_conjoint.do"
do "Scripts\functions\function_addplot.do"

*** Add Labels
label variable trust_industry "Trust in Industry"
label variable trust_ngo "Trust in NGOs"
label variable trust_inst "Trust in political Institutions"
label variable trust_univ "Trust in Universities"
label variable actor "Conjoint attribute: actor"
label variable year "Conjoint attribute: year"
label variable reporting "Conjoint attribute: reporting"
label variable monitoring "Conjoint attribute: monitoring"
label variable regulation "Conjoint attribute: regulation"
label variable sanction "Conjoint attribute: sanction"

****************************************************************************

*Types of Trust and Environmental Policy Support 

****************************************************************************
qui logistic binary ///
	trust_inst trust_univ trust_ngo trust_industry ///
	actor year reporting monitoring regulation sanction, cluster(PubId)
eststo int_tr

estadd scalar N_clusters = e(N_clust)
*estadd scalar N = e(N)
esttab int_tr using "Tables/logreg_results.tex", ///
    title("Logistic Regression Results") ///
    label ///
    compress ///
    cells("b(fmt(3) star) se(fmt(3))") ///
    star(* 0.10 ** 0.05 *** 0.01) ///
    alignment(D{.}{,}{-1}) ///
    keep(trust_inst trust_univ trust_ngo trust_industry actor year reporting monitoring regulation sanction) ///
    stats(N N_clusters, fmt(0) labels("Observations" "Number of clusters")) ///
    addnote("Displayed are log odds from a logistic regression model controlling for trust in four actors and six policy process and design characteristics. The outcome measure is a binary indicator for a policy proposal with a random set of characteristics. All variables are standardized. Standard errors in parentheses are clustered by PubId. ∗ 𝑝 < 0.10, ∗∗ 𝑝 < 0.05, ∗∗∗ 𝑝 < 0.01") ///
    replace

************ Trust in institutions *******
qui logistic binary ///
	trust_inst  ///
	actor year reporting monitoring regulation sanction, cluster(PubId)
eststo int_tr

loc ylab 0.35(.05).6
est rest int_tr
qui margins, at(trust_inst=(-2(1)2)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in political institutions", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh) lwidth(0.5)) ///
	ci1opts(lc(edkblue)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(m_trust_inst, replace) 
		addplot:( ///
		hist trust_inst if trust_inst <= 2, percent yaxis(2) width(0.8) fcolor(gs14%20) lc(gs14%20) ///
		ylab(10(20)50, ///
			axis(2) nogrid labs(vsmall) ang(90)) ///
		yti("% Respondents' trust levels", size(small) axis(2)) ///
		yscale(alt axis(2))) 


		
************ Trust in universities *******
qui logistic binary ///
	trust_industry trust_inst trust_univ trust_ngo ///
	actor year reporting monitoring regulation sanction, cluster(PubId)
eststo int_tr
	
loc ylab 0.35(.05).6
est rest int_tr
qui margins, at(trust_univ=(-2(1)2)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in universities", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh) lwidth(0.5)) ///
	ci1opts(lc(edkblue)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(m_trust_univ, replace) 
		addplot:( ///
		hist trust_univ if trust_univ >= -2 & trust_univ <= 2, percent yaxis(2) width(0.8) fcolor(gs14%20) lc(gs14%20) ///
		ylab(10(20)50, ///
			axis(2) nogrid labs(vsmall) ang(90)) ///
		yti("% Respondents' trust levels", size(small) axis(2)) ///
		yscale(alt axis(2))) 


************ Trust in NGOs *******
loc ylab 0.35(.05).6
est rest int_tr
qui margins, at(trust_ngo=(-2(1)2)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in NGOs", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh) lwidth(0.5)) ///
	ci1opts(lc(edkblue)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(m_trust_ngo, replace) 
		addplot:( ///
		hist trust_ngo if trust_ngo <= 2, percent yaxis(2) width(0.8) fcolor(gs14%20) lc(gs14%20) ///
		ylab(10(20)50, ///
			axis(2) nogrid labs(vsmall) ang(90)) ///
		yti("% Respondents' trust levels", size(small) axis(2)) ///
		yscale(alt axis(2))) 

		


************ Trust in industry *******
qui logistic binary ///
	trust_industry trust_inst trust_univ trust_ngo  ///
	actor year reporting monitoring regulation sanction, cluster(PubId)
eststo int_tr

loc ylab 0.35(.05).6
est rest int_tr
qui margins, at(trust_industry=(-2(1)2)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in industry", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh) lwidth(0.5)) ///
	ci1opts(lc(edkblue)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(m_trust_industry, replace) 
	addplot:( ///
		hist trust_industry if trust_industry <= 2, percent yaxis(2) width(0.8) fcolor(gs14%20) lc(gs14%20) ///
		ylab(10(20)50, ///
			axis(2) nogrid labs(vsmall) ang(90)) ///
		yti("% Respondents' trust levels", size(small) axis(2)) ///
		yscale(alt axis(2))) 
	
gr combine ///
	m_trust_inst, ///
	row (1) ///
	ysize(10) xsize(8) ///
	graphregion(color(white)) ///
	name(models_trust_A, replace)
gr export "Plots\Figure1_political.png", replace width(3000)
	
gr combine ///
	m_trust_univ ///
	m_trust_ngo ///
	m_trust_industry, ///
	row (1) ///
	ysize(6) xsize(14) ///
	graphregion(color(white)) ///
	name(models_trust_B, replace)
	
gr export "Plots\Figure1_non-political.png", replace  width(3000)
	

****************************************************************************

*Interaction: Trust and Hybrid Policy Designs 

****************************************************************************
	
************ Trust in institutions *******
loc ylab 0.2(.2).8

//Stringency
qui logistic binary ///
	ib1.stringency_f##c.trust_inst ///
	actor##c.trust_inst trust_univ trust_ngo trust_industry year, cluster(PubId)
eststo int_tr

est rest int_tr
qui margins, at(trust_inst=(-2(1)2) stringency_f=(1(1)3)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in institutions", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend(off) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(int_stringency_trustinst, replace) 
	

	
************ Trust in universities *******
loc ylab 0.2(.2).8

//Stringency
qui logistic binary ///
	ib1.stringency_f##c.trust_univ ///
	actor##c.trust_univ trust_inst trust_ngo trust_industry year, cluster(PubId)
eststo int_univ

est rest int_univ
qui margins, at(trust_univ=(-2(1)2) stringency_f=(1(1)3)) post
eststo int_mar_univ_strin
est res int_mar_univ_strin
marginsplot, ///
	title("Trust in experts", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(int_stringency_trustuniv, replace) 
	

	
************ Trust in NGOs *******
loc ylab 0.2(.2).8

//Stringency
qui logistic binary ///
	ib1.stringency_f##c.trust_ngo ///
	actor##c.trust_ngo trust_univ trust_inst trust_industry year, cluster(PubId)
eststo int_tr

est rest int_tr
qui margins, at(trust_ngo=(-2(1)2) stringency_f=(1(1)3)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in NGOs", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(int_stringency_trustngo, replace) 
	
	

************ Trust in Industry *******
loc ylab 0.2(.2).8

//Stringency
qui logistic binary ///
	ib1.stringency_f##c.trust_industry ///
	actor##c.trust_industry trust_univ trust_ngo trust_inst year, cluster(PubId)
eststo int_tr

est rest int_tr
qui margins, at(trust_industry=(-2(1)2) stringency_f=(1(1)3)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Trust in industry", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("Pr(Selecting Proposal)")  ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	legend( ///
	pos(6) size(small) row(1)) ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	ylabel(,labsize(small)) ///
	graphregion(color(white)) ///
	name(int_stringency_trustindustry, replace) 
	
	
//Make combined interacton figure
gr combine ///
	int_stringency_trustinst, ///
	row (1) ///
	ysize(14) xsize(10) ///
	graphregion(color(white)) ///
	name(models_trust_A, replace)
gr export "Plots\SI_trust_political.png", replace
	
grc1leg ///
	int_stringency_trustuniv ///
	int_stringency_trustngo ///
	int_stringency_trustindustry, ///
	ycomm row(1) ///
	ysize(6) xsize(18) ///
	graphregion(color(white)) ///
	name(models_trust_B, replace)
	
gr export "Plots\SI_trust_non-political.png", replace

